package contest.dweek33;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/8/24 15:57
 */
public class Solution3 {

    public int minOperations(int[] nums) {
        int res = 0;
        boolean f = false;
        for (int i = 0; i < nums.length; i++) {
            if ((nums[i] & 1) == 1) {
                res++;
                nums[i]--;
            }
            if (!f && nums[i] != 0) f = true;
        }
        if (!f) return res;
        res++;
        for (int i = 0; i < nums.length; i++) {
            nums[i] = nums[i] >> 1;
        }
        return res + minOperations(nums);
    }
}
